package com.springboot.hotel.config;

import com.springboot.hotel.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;
//配置类
@Configuration
public class ApplicationConfig extends WebMvcConfigurationSupport {
//    配置拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截所有请求
//        注册拦截器
        registry.addInterceptor(new LoginInterceptor()).addPathPatterns
//                拦截所有请求，除了登录页面和登录接口
                ("/**").excludePathPatterns
//                放行静态资源
                ("/","/login","/email","/sendCode","/emailLogin","/captcha/**","/verCode")
                .excludePathPatterns("/static/**");
    }
//    配置静态资源
@Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
//        配置静态资源路径
        registry.addResourceHandler("/static/**").
                addResourceLocations("classpath:/static/");
    }
}
